package com.zl.tby.vo;

import com.zl.tby.core.base.enums.TbyEducationViewCategoryEnum;
import com.zl.tby.core.base.enums.TbyFileTypeEnum;
import com.zl.tby.core.base.util.ToolsUtil;
import com.zl.tby.model.TbyEducationView;
import lombok.Data;

import java.time.format.DateTimeFormatter;

/**
 * 视图管理
 * @author changpeng
 * @version 1.0
 * @since 2024/8/14 9:30
 */
@Data
public class TbyEducationViewForm extends TbyEducationView {
    private String businessName;
    private String createDateFormat;
    private String categoryValue;
    private String typeValue;
    private String formData;
    private String ids;

    public TbyEducationView createEntity() {
        TbyEducationView entity = new TbyEducationView();
        entity.setCategory(this.getCategory());
        entity.setType(this.getType());
        entity.setBusinessId(this.getBusinessId());
        entity.setFileUrl(this.getFileUrl());
        entity.setFileName(this.getFileName());
        entity.setFileSize(this.getFileSize());
        return entity;
    }

    public void updateEntity(TbyEducationView entity) {
        entity.setCategory(this.getCategory());
        entity.setType(this.getType());
        entity.setBusinessId(this.getBusinessId());
        entity.setFileUrl(this.getFileUrl());
        entity.setFileName(this.getFileName());
        entity.setFileSize(this.getFileSize());
    }

    public void fillExtendProp() {
        this.createDateFormat = this.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        this.typeValue = TbyFileTypeEnum.getValueByCode(this.getType());
        this.categoryValue = TbyEducationViewCategoryEnum.getValueByCode(this.getCategory());
    }
}
